<?php
$this->breadcrumbs = array(
	'All Users' => array('users/index'),
	$user->name
);
?>
<div class="main-title">
	<div class="float-left">
		<h1><?php echo $user->name; ?></h1>
    </div>
    <div class="controls">
        <a id="addUser" class="link-button with-icon" href="<?php echo $this->createUrl('users/update', array('id' => $user->id)); ?>">
            <img src="/images/icons/fugue/pencil.png" />
            Edit
        </a>
    </div>
</div>
<div class="grid_10">
	<div class="section highlighted-blue">
		<div id="agent-card" class="block">
			<h2>Contact Information</h2>
			<div class="agent-photo">
				<img src="<?php echo $user->getPhoto(); ?>" width="50" />
			</div>
			<div class="agent-contact-details">
				<div class="agent-name"><?php echo $user->name; ?></div>
				<?php if (!empty($user->license_no)): ?>
					<div class="agent-license_no"><?php echo $user->license_no; ?></div>
				<?php endif; ?>
				<?php if ($user->getEffectiveDesignation()): ?>
					<div class="agent-designation"><?php echo $user->getEffectiveDesignation()->name; ?></div>
				<?php endif; ?>
				<div class="agent-contact-detail-section">
					<div class="agent-agency"><?php echo $user->agency->name ?></div>
				</div>
				<div class="agent-contact-detail-section">
					<?php if (!empty($user->mobile)): ?>
						<div class="agent-contact-detail clearfix">
							<img src="/images/icons/fugue/phonecall.png" width="16" height="16" class="float-left" />
							<div><?php echo $user->mobile; ?></div>
						</div>
					<?php endif; ?>
					<?php if (!empty($user->email)): ?>
						<div class="agent-contact-detail clearfix">
							<img src="/images/icons/fugue/mail.png" width="16" height="16" class="float-left" />
							<div><a href="mailto:<?php echo $user->email; ?>" class="blue link"><?php echo $user->email; ?></a></div>
						</div>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>
	<div class="section">
		<div id="user-info" class="block">
			<h2>User Information</h2>
			<div class="">
				<?php
				$this->widget('zii.widgets.CDetailView', array(
					'data' => $user,
					'attributes' => array(
						array(
							'label' => 'Username',
							'type' => 'raw',
							'value' => $user->username,
						),
						'last_login' => array(
							'label' => 'Last Login',
							'value' => !empty($user->last_login) ? date("j M, Y G:ia", strtotime($user->last_login)) : ''
						),
						'activate_date' => array(
							'label' => 'Joined',
							'value' => date("j M, Y G:ia", strtotime($user->activate_date))
						)
					),
					'htmlOptions' => array(
						'class' => 'detail-view plain'
					)
				));
				?>
			</div>
		</div>
	</div>
	<div class="section">
		<div id="user-stats" class="block">
			<h2>User Scores / Statistics</h2>
			<div class="">
				<?php
				$this->widget('zii.widgets.CDetailView', array(
					'data' => $user,
					'attributes' => array(
						array(
							'label' => 'Next Gross Commissions Target',
							'type' => 'raw',
							'value' => Yii::app()->numberFormatter->formatCurrency($user->getNextLevelScores('gross_comm'), "$ ")
						),
						array(
							'label' => 'Total Gross Commissions Received',
							'type' => 'raw',
							'value' => Yii::app()->numberFormatter->formatCurrency($user->getTotalScoreCommsReceived(new CDbExpression("UTC_TIMESTAMP()"), "gross_comm"), "$ "),
						),
						array(
							'label' => 'Adjustments for Gross Commissions',
							'type' => 'raw',
							'value' => Yii::app()->numberFormatter->formatCurrency($user->getTotalAdjustedAmount(new CDbExpression("UTC_TIMESTAMP()"), "gross_comm"), "$ "),
						),
						array(
							'label' => 'Actual Gross Commissions Received',
							'type' => 'raw',
							'value' => Yii::app()->numberFormatter->formatCurrency($user->getActualCommsReceived(new CDbExpression("UTC_TIMESTAMP()"), "gross_comm"), "$ "),
						),
						array(
							'label' => 'Next Approved Cases Target',
							'type' => 'raw',
							'value' => $user->getNextLevelScores('units_transacted')
						),
						array(
							'label' => 'Total Cases Approved',
							'type' => 'raw',
							'value' => $user->getTotalScoreCasesApproved(new CDbExpression("UTC_TIMESTAMP()"), "units_transacted")
						),
						array(
							'label' => 'Actual Cases Approved',
							'type' => 'raw',
							'value' => $user->getActualCasesApproved(new CDbExpression("UTC_TIMESTAMP()"), "units_transacted"),
						),
						array(
							'label' => 'Total Cases Fully Paid',
							'type' => 'raw',
							'value' => $user->getTotalScoreCasesFullyPaid(new CDbExpression("UTC_TIMESTAMP()"), "units_transacted")
						),
						array(
							'label' => 'Actual Cases Fully Paid',
							'type' => 'raw',
							'value' => $user->getActualCasesFullyPaid(new CDbExpression("UTC_TIMESTAMP()"), "units_transacted"),
						),
					),
					'htmlOptions' => array(
						'class' => 'detail-view plain',
					)
				));
				?>
			</div>
		</div>
	</div>
</div>
<div class="grid_6">
	&nbsp;
</div>